	var zaehler = 1;
	function loadgame(ziel) {
		var loadtext = document.getElementById('progressbarloadtext').style;
		var percentlimit = 35;
		var speedindex = 10;
		var percentlimitstatus = "enable";
		speedindex = speedindex * 2;
		if (zaehler < ziel) {
			zaehler = zaehler + 1;
			document.getElementById("progressbarloadbg").style.width = zaehler + "px";
			var prozent = Math.round(zaehler / ziel * 100);
			document.getElementById("progresstext").innerHTML = prozent + " %";
			window.setTimeout("loadgame('" + ziel + "')", speedindex);
			if ((prozent >= percentlimit) & (percentlimitstatus == "enable")) {
				loadtext.display = 'block';
			}
		} else {
			zaehler = 1;
			window.hide();
		}
	}

	function hide() {
		var intro = document.getElementById('intro').style;
		var showprogressbar = document.getElementById('showprogressbar').style;
		var loadtext = document.getElementById('progressbarloadtext').style;
		var game = document.getElementById('my_game').style;

		// intro.display = 'none';
		// showprogressbar.display = 'none';
		// loadtext.display = 'none';
		game.width = '100%';
		game.height = '100%';

		zaehler = 400;
	}
	function reload_game() {
		var v_html = $("#bordeswf").html();
		// remove existing Flash from DOM
		$("#bordeswf").remove();
		// add new HTML to DOM
		$("#play_game").append('<div id="bordeswf">' + v_html + '</div>');
	}

	$(function () {

		if ($('#progressbarloadbg').size() > 0) {
			// setTimeout('loadgame(400)', 0);
			(function showstat() {
				_width = $('#progressbarloadbg').width();
				$('#progresstext').text(Math.round((_width/400) * 100, 0) + ' %');
				if (_width < 400) setTimeout(showstat, 1);
				else {
					$('#intro').hide();
					$('#my_game').show();
				}
			}());
			$('#progressbarloadbg').width(400);
		}
		$('#replay_game').click(reload_game);
		if ($('#game_zoom').size() > 0) {
			$('#game_zoom').click(function () {
				$zoom = $(this).attr('data-zoom');
				if ($zoom == '1') {
					//zoom in;
					$(this).text('Thu nhỏ');
					$(this).attr('data-zoom', '0');
					$playgame = $('#playgame');

					if ($playgame.attr('small-width')) {
						gwidth = $playgame.attr('small-width');
						gheight = $playgame.attr('small-height');
					} else {
						gwidth = $playgame.attr('width');
						gheight = $playgame.attr('height');

						$playgame.attr('small-width', gwidth);
						$playgame.attr('small-height', gheight);
					}

					// if ($(window).height() < $(window).width()) {
						// ratio = ($(window).height() / gheight);
						ratio = (800 / gwidth);
						newgwidth = 800;
						newgheight = gheight * ratio;
					// } else {
						// ratio = ($(window).width() / gwidth);
						// newgwidth = gwidth * ratio;
						// newgheight = gheight * ratio;
					// }

					$playgame.attr('width', newgwidth);
					$playgame.attr('height', newgheight);
					$('#sidebarright').css('margin-top', newgheight + 50);
					// $('#playgame').css('margin-left', 50);
				} else {
					//zoom out;
					$(this).text('Phóng to');
					$(this).attr('data-zoom', '1');
					$playgame.attr('width', $playgame.attr('small-width'));
					$playgame.attr('height', $playgame.attr('small-height'));
					$('#sidebarright').css('margin-top', '0');
					// $('#playgame').css('margin-left', 0);
				}
				setTimeout(function (){
					$('body').animate({
						scrollTop : $('#play_game').offset().top,
					}, 400);
				},500)
			});
		}
	});
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}